

use cgmath::{BaseFloat, Point3, Vector3, Vector4, Matrix4};

use camera::Camera;

///位置变化
pub struct Person<S=f32>{
    location: Point3<S>,
}

pub struct GameMaster<S=f32>{
    ///相机距离玩家的距离
    distance: S,
    camera: Camera<S>,
    person: Person<S>,
}

impl <S: BaseFloat + Copy> Person<S>{
    pub fn new(location: Point3<S>) -> Person<S>{
        Person{
            location
        }
    }

    pub fn location(&self) -> Point3<S>{
        self.location
    }
}

impl <S: BaseFloat + Copy> GameMaster<S>{
    pub fn new(distance: S, location: Point3<S>) -> GameMaster<S>{
        let person = Person::new(location);
        let x: S = location.x - distance;
        let y: S = location.y;
        let z: S = location.z - distance;
        let c = Point3::new(x, y, z);
        let camera = Camera::new(c, location);
        GameMaster{
            distance,
            person,
            camera
        }
    }

    pub fn view(&self) -> Matrix4<S>{
        self.camera.view()
    }
}